<template>
  <el-dialog
    title="选择风险点"
    :close-on-click-modal="false"
    :visible.sync="visible"
    class="JNPF-dialog JNPF-dialog_center"
    lock-scroll
    append-to-body
    width="1200px"
  >
    <el-row class="JNPF-common-search-box" :gutter="16">
      <div class="JNPF-common-search-box-right">
        <el-tooltip
          effect="dark"
          :content="$t('common.refresh')"
          placement="top"
        >
          <el-link
            icon="icon-ym icon-ym-Refresh JNPF-common-head-icon"
            :underline="false"
            @click="refresh()"
          />
        </el-tooltip>
      </div>
    </el-row>
    <JNPF-table
      ref="multipleTable"
      v-loading="listLoading"
      :data="list"
      hasC
      @selection-change="handleSelectionChange"
      :border="false"
    >
      <el-table-column prop="mc" label="名称" />
      <el-table-column prop="lx" label="类型" />
      <el-table-column prop="qumc" label="区域名称" />
    </JNPF-table>
    <pagination
      :total="total"
      :page.sync="listQuery.currentPage"
      :limit.sync="listQuery.pageSize"
      @pagination="init"
    />
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">{{
        $t("common.cancelButton")
      }}</el-button>
      <el-button type="primary" @click="select()">{{
        $t("common.confirmButton")
      }}</el-button>
    </span>
  </el-dialog>
</template>

<script>
import request from "@/utils/request";
import { previewDataInterface } from "@/api/systemData/dataInterface";
export default {
  data() {
    return {
      visible: false,
      listLoading: true,
      keyword: "",
      list: [],
      total: 0,
      checked: [],
      query: {},
      listQuery: {
        currentPage: 1,
        pageSize: 20,
      },

      rightHeader1: [{ label: "排查人", key: "pcrId" }],
      // rightsDate:[],

      pcr: [],
    };
  },
  created() {},
  methods: {
    init(fxdPcrList) {
      this.visible = true;
      this.listLoading = true;
      // if(fxdPcrList.length == 0){
      let query = {
        ...this.listQuery,
        ...this.query,
      };
      request({
        url: `/api/System/YHPCXXFXD`,
        method: "get",
        data: query,
      }).then((res) => {
        this.list = res.data;
        this.listLoading = false;
        this.total = res.pagination.total;
        this.$nextTick(() => {
          this.tableHeight = "100%";
          // if(this.list.length > 0){
          //   for(let i=0;i<this.list.length;i++){
          //     for(let r=0;r<this.checked.length;r++){
          //       if(this.list[i].id == this.checked[r].id){
          //         this.$refs.multipleTable.toggleRowSelection(this.list[i]);
          //       }
          //     }
          //   }
          // }
        });
      });
      // }else{
      this.checked = fxdPcrList;
      this.listLoading = false;
      // }
    },
    refresh() {
      // this.keyword = "";
      this.init();
    },
    select() {
      if (!this.checked.length) return;
      this.visible = false;
      this.$emit("refreshDataList", this.checked);
    },
    handleSelectionChange(val) {
      this.checked = val;
    },
  },
};
</script>
<style lang="scss" scoped>
>>> .el-dialog__body {
  height: 70vh;
  padding: 0 0 10px !important;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  .JNPF-common-search-box {
    margin-bottom: 0;
    .JNPF-common-search-box-right {
      padding: 10px 10px 0 0;
    }
  }
}
</style>